package com.eqdd.yiqidian.ui.gongneng.daka;

import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.util.SparseArray;
import android.view.View;

import com.eqdd.yiqidian.DakaDetailActivityCustom;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.adapter.slimadapter.SlimAdapterEx;
import com.eqdd.yiqidian.adapter.slimadapter.SlimInjector;
import com.eqdd.yiqidian.adapter.slimadapter.viewinjector.IViewInjector;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.bean.rebuild.ClockBean;
import com.eqdd.yiqidian.bean.rebuild.ClockHistoryListResultBean;

public class DakaDetailActivity extends BaseActivity {
    private DakaDetailActivityCustom dataBinding;
    private ClockHistoryListResultBean bean;
    private SlimAdapterEx<ClockBean> slimAdapterEx;
    SparseArray<String> statusMap = new SparseArray();

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_daka_detail);
        statusMap.put(0, "正常");
        statusMap.put(1, "迟到");
        statusMap.put(2, "早退");
        statusMap.put(-1, "打卡");
        statusMap.put(-2, "漏打卡");
        statusMap.put(-3, "未开始");
    }

    @Override
    public void initData() {
        bean = (ClockHistoryListResultBean) getIntent().getSerializableExtra("bean");
        initTopTitleBar(View.VISIBLE, bean.getDate());
        dataBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        slimAdapterEx = SlimAdapterEx.create().register(R.layout.list_item_53, new SlimInjector<ClockBean>() {
            @Override
            public void onInject(ClockBean data, IViewInjector injector) {

                injector.text(R.id.tv_upper_left, "打卡时间：" + data.getCreateTime())
                        .text(R.id.tv_upper_right, "规定时间：" + data.getClockTime())
                        .text(R.id.tv_down_left, "打卡wifi:" + data.getWIFIName())
                        .text(R.id.tv_down_right, statusMap.get(data.getStatus()))
                        .textColor(R.id.tv_down_right, data.getStatus()==0? Color.parseColor("#000000"):Color.parseColor("#ff0000"))
                        .text(R.id.tv_down, data.getPlace());
            }
        }).attachTo(dataBinding.recyclerView).updateData(bean.getList());
    }

    @Override
    public void setView() {

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

        }
    }
}
